<%@ page import="com.iweb.constant.UserAction" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
  <base href="<%=basePath%>">
  <title>修改用户</title>
  <link href="statics/css/admin.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<%@include file="navbar.jsp"%>
<div id="wrapper">
  <%@include file="siderbar.jsp"%>
  <di class="main-content">
    <form action="user.do?action=<%=UserAction.DOMODIFY%>" method="post">
      <%--   设置隐藏域，保存用户id，以便后台修改数据--%>
      <input type="hidden" name="id" value="${requestScope.user.id}">
      <p>登录名：<input type="text" name="loginName" value="${requestScope.user.loginName}" readonly></p>
        <p>姓名：<input type="text" name="userName" value="${requestScope.user.userName}"><span>${requestScope.userNameErrorMessage}</span></p>
      <p>性别：
        <input id="male" type="radio" name="sex" value="1" checked>男&nbsp;
        <input id="famale" type="radio" name="sex" value="0">女
        <span>${requestScope.sexErrorMessage}</span>
      </p>
      <p>身份证号：<input type="text" name="identityCode" size="18" value="${requestScope.user.identityCode}"></p>
      <p>邮箱：<input type="text" name="email" value="${requestScope.user.email}"></p>
      <p>手机号：<input type="text" name="mobile" value="${requestScope.user.mobile}"></p>
      <p>用户类型：
        <select name="type" id="type">
          <option value="1">系统管理员</option>
          <option value="0">商城会员</option>
        </select>
      </p>
      <p><span>${requestScope.userIdErrorMessage}</span></p>
      <p>
        <input type="submit" value="保存">
      </p>
    </form>
  </di>
</div>
<script>
  //设置性别
  let sex=${requestScope.user.sex};
  if(sex==1){
      document.getElementById("male").checked=true;
  }else{
      document.getElementById("male").checked=true;
  }

  //设置会员类型
  let type=${requestScope.user.type};
  let options=document.getElementById("type").options;
  for(let i=0;i<options.length;i++){
      if(options[i].value==type){
          options[i].selected=true;
          break;
      }
  }
</script>
</body>
</html>
